package com.ymatou.query.trading.api.testcase;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetBuyerOrderInfoBean;
import com.ymatou.query.trading.api.service.GetBuyerOrderInfoV2Call;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.utils.EnvSetup;

/**
 * 获取买家订单列表
 */
@TestSuite
public class Ts_GetBuyerOrderInfoV2 {

	private static GetBuyerOrderInfoBean getBuyerOrderInfoBean;
	private static GetBuyerOrderInfoV2Call getBuyerOrderInfoV2Call;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取买家订单列表");
	}

	@Before
	public void caseUp() {
		getBuyerOrderInfoBean = new GetBuyerOrderInfoBean();
		getBuyerOrderInfoV2Call = new GetBuyerOrderInfoV2Call();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getBuyerOrderInfoV2Call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBuyerOrderInfoV2_001() {
		Logger.start(true, "获取买家订单列表, 参数全传，查询成功");
		try {
			getBuyerOrderInfoBean.setOrderId(105842530);
			getBuyerOrderInfoBean.setUserId(20238699);
			getBuyerOrderInfoV2Call.setData(getBuyerOrderInfoBean);
			getBuyerOrderInfoV2Call.callService();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBuyerOrderInfoV2_002() {
		Logger.start(true, "获取买家订单列表, 只传OrderId，查询失败");
		try {
			getBuyerOrderInfoBean.setOrderId(112443993);
			getBuyerOrderInfoV2Call.setData(getBuyerOrderInfoBean);
			getBuyerOrderInfoV2Call.callService();
			Logger.verifyEquals("400", getBuyerOrderInfoV2Call.getCode(), " 验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBuyerOrderInfoV2_003() {
		Logger.start(true, "获取买家订单列表, 只传UserId，查询失败");
		try {
			getBuyerOrderInfoBean.setUserId(20238699);
			getBuyerOrderInfoV2Call.setData(getBuyerOrderInfoBean);
			getBuyerOrderInfoV2Call.callService();
			Logger.verifyEquals("400", getBuyerOrderInfoV2Call.getCode(), " 验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBuyerOrderInfoV2_004() {
		Logger.start(true, "获取买家订单列表, OrderId不存在，OrderInfo为null");
		try {
			getBuyerOrderInfoBean.setOrderId(-212443993);
			getBuyerOrderInfoBean.setUserId(20238699);
			getBuyerOrderInfoV2Call.setData(getBuyerOrderInfoBean);
			getBuyerOrderInfoV2Call.callService();
			Logger.verifyEquals("200", getBuyerOrderInfoV2Call.getCode(), " 验证code");
			Logger.verifyEquals("null",getBuyerOrderInfoV2Call.getData().getString("OrderInfo"), "验证OrderInfo为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}